home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Headers / misckit / MiscSerialPort.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-25  |  2.6 KB  |  81 lines

  1. //
  2. //    MiscSerialPort.h -- an OO wrapper around the serial ports
  3. //        Written by Matt Brandt Copyright (c) 1994 by Matt Brandt.
  4. //                Version 2.0.  All rights reserved.
  5. //        This notice may not be removed from this source code.
  6. //
  7. //    This object is included in the MiscKit by permission from the author
  8. //    and its use is governed by the MiscKit license, found in the file
  9. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  10. //    for a list of all applicable permissions and restrictions.
  11. //    
  12.  
  13. // Note:  The following possible problem is reported by Carl Lindberg
  14. // (lindberg@BLaCKSMITH.com)
  15. /*
  16. He [Mike Hovan] also had a very funky problem with MiscSerialPort.
  17. Whenever DPSRemoveFd() was called, the program would hang -- until
  18. some (any) other event happened, at which point the program would
  19. continue merrily on its way.   He showed me -- the program would hang,
  20. he would hit the shift key, and the program would continue.  His
  21. solution was to stick a dummy event into the queue right before any
  22. call to DPSRemoveFd().  And this worked.  !?!?!  This could be
  23. something particular to his setup; I can't believe no one else noticed
  24. this before if it was a common problem.
  25. */
  26.  
  27. #import <appkit/appkit.h>
  28. #import    <sgtty.h>
  29.  
  30. #define MISC_NO_PARITY        0
  31. #define MISC_ODD_PARITY        1
  32. #define MISC_EVEN_PARITY    2
  33.  
  34. #ifndef B19200            // added for 3.0 systems by Don
  35. #define B19200 EXTA
  36. #endif
  37.  
  38. #ifndef B38400            // added for 3.0 systems by Don
  39. #define B38400 EXTB
  40. #endif
  41.  
  42. @interface MiscSerialPort:Object
  43. {
  44.     char            portName[64];        // path to port device
  45.     BOOL            connected;            // YES if port open
  46.     BOOL            suspended;            // YES if port is suspended
  47.     int                fd;                    // file descriptor when open
  48.     id                delegate;            // who do we send data to?
  49.     int                currentBaud;        // current baud rate
  50.     int                currentParity;        // current parity
  51. }
  52.  
  53. - init;                                    // initialize defaults
  54. - setDeviceName: (const char *)name;    // set device name to open
  55. - setBaud: (int)baud;                    // set port baudrate
  56. - setBaudByName: (const char *)speed;    // set by speed string
  57. - setParity: (int)parity;                // set parity
  58. - dropDTR;
  59. - raiseDTR;
  60. - (BOOL)connect;                        // connect with current parameters
  61. - disconnect;                            // disconnect from current port
  62. - setDelegate: theConsumer;                // who gets received data
  63. - delegate;                                // return current consumer
  64. - transmitChars: (const char *)buffer    // transmit a stream of data
  65.     length: (int)length;
  66. - suspend;
  67. // - continue;                            // ** obsolete **
  68. - resume;
  69. - (BOOL)suspended;
  70. - (int)filedes;
  71. - free;
  72.  
  73. @end
  74.  
  75. @interface Object(MiscSerialPortDelegate)
  76.  
  77. - receiveChars: (char *)buffer length: (int)length;
  78. - hangup;
  79.  
  80. @end
  81.